import Vue from 'vue'
import 'normalize.css/normalize.css'// A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN'
import App from './App'
import router from './router'
import store from './store'
import '@/icons' // icon
import '@/permission' // 权限
import {default as api} from './utils/api'
import {hasPermission} from "./utils/hasPermission";
import md5 from 'js-md5'
import JsEncrypt from 'jsencrypt'
import myCharts from './utils/myCharts.js'


// 引入echarts
Vue.use(myCharts)

Vue.prototype.$jsEncrypt = JsEncrypt
Vue.prototype.$md5 = md5;
Vue.use(ElementUI, {locale})
Vue.prototype.api = api
//全局的常量
Vue.prototype.hasPerm = hasPermission

Vue.prototype.$encruption = function (obj) {
  // console.log("我已经进入encruption了")
  let encrypt = new JSEncrypt();
  encrypt.setPublicKey
  (
    `-----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAndYulZS6espqkERwaJAATbvGW2fvaeRlxjw1ll9f7OHHT2MqM6ZnJiTn3tGh8FGTE6CMc3I78T/g3gpWv/pf4PYUmUcPXjKf+3EaWeCJQ8ovLwjBZbIGtl1bFX3BQzNFTHbyZlkpUC9Lcx0+n7DNmo/kEWzae9lFFLv9WIAN04ojYcmKO2DVFSxHh6/ODIMPIRwFuDUOE8vkZV1PX7/R48XsIH7FJTfIBhQB57Moo19u2Hu6PyJI3AwABJQpsKyI0jtJ0r0MX3oZlkQb+5XCLg5VZTGGEnbSInS9/Qo+osUQiJMTbtu+9tu6XD1WAHTwQY+ChDa0GfIGvAVXjQi8fQIDAQAB
    -----END PUBLIC KEY-----`
  )
  // console.log("encry:"+encrypt.encrypt(obj));
  return encrypt.encrypt(obj);
}


//生产环境时自动设置为 false 以阻止 vue 在启动时生成生产提示。
Vue.config.productionTip = (process.env.NODE_ENV != 'production')

new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {App}
})
